package com.elysia.newsservice.controller;

import com.elysia.newsservice.domain.dto.GameNewsDTO;
import com.elysia.newsservice.domain.vo.GameNewsVO;
import com.elysia.newsservice.result.Result;
import com.elysia.newsservice.service.IGameNewsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 游戏公告控制层
 **/
@RestController
@RequestMapping("/game-news")
@RequiredArgsConstructor
@Slf4j
public class GameNewsController {
    private final IGameNewsService gameNewsService;
    @PostMapping
    public Result<GameNewsVO> addGameNews(@RequestBody GameNewsDTO gameNewsDTO){
        log.info("添加公告{}", gameNewsDTO);
        return gameNewsService.addGameNews(gameNewsDTO);
    }
    @GetMapping
    public Result<List<GameNewsVO>> getAllGameNews(){
        log.info("获取所有公告");
        return gameNewsService.getAllGameNews();
    }
    @PutMapping("/{id}")
    public Result<GameNewsVO> updateGameNews(@PathVariable Long id, @RequestBody GameNewsDTO gameNewsDTO){
        log.info("更新公告{}: {}", id, gameNewsDTO);
        return gameNewsService.updateGameNews(id, gameNewsDTO);
    }
    @DeleteMapping("/{id}")
    public Result<String> deleteGameNews(@PathVariable Long id){
        log.info("删除公告: {}", id);
        return gameNewsService.deleteGameNews(id);
    }
}
